<?php
	$u_consultant = isset($_GET['consultant'])?$_GET['consultant']:'';
?>

<?php $this->load->view('header');?>

<div class="page-container">
	<?php $this->load->view('sidebar');?>
	<!-- BEGIN CONTENT -->
	<div class="page-content-wrapper">
		<div class="page-content">
			<?php $this->load->view('user/_sub_nav');?>
			<div class="row">
				<div class="col-md-12">

					<div class="table-toolbar">
						<div class="form-inline">
							<label>
								查看范围
								<select name="" id="clue_range_select" class="form-control">
									<option value="<?php echo site_url('/sale/receptions');?>">所有线索</option>
									<?php foreach ($consultants as $consultant) :?>
				                        <option value="<?php echo site_url('/sale/receptions?consultant='.$consultant['id']);?>" <?php echo $u_consultant==$consultant['id']?'selected="selected"':'';?>>
				                            <?php echo $consultant['nickname']; ?>的线索
				                        </option>
				                    <?php endforeach; ?>
								</select>
							</label> 

							<div class="pull-right">
								<?php if(has_permission('sale/tracks','add')):?>
								<a href="<?php echo site_url(base_url() . '/sale/tracks/create');?>" class="btn blue" >
								 <i class="fa fa-plus"></i> 新建 
								</a> 
								<?php endif;?>

							</div>

						</div>
					</div>

					<table class="table table-hover" id="tracks_table">
						<thead>
							<tr>
								<th class="table-checkbox"><input type="checkbox" class="group-checkable" data-set="#tracks_table .checkboxes"></th>
								<th><?php echo lang('clue_track_title');?></th>
								<th><?php echo lang('clue_student_name_no');?></th>
								<th><?php echo lang('clue_track_content');?></th>
								<th><?php echo lang('clue_trade_wish');?></th>
								<th><?php echo lang('clue_track_result');?></th>
								<th><?php echo lang('clue_track_date');?></th>
								<th><?php echo lang('clue_next_track_date');?></th>
								<th><?php echo lang('clue_consultant');?></th>
								<th><?php echo lang('actions');?></th>
							</tr>
						</thead>

					</table>

					<div class="btn-group">
						<button id="track_dist_btn" class="btn yellow" data-target="#dist_modal" data-toggle="modal">
						 转移 <i class="fa fa-plus"></i>
						</button>
					</div>
<!--					<div class="btn-group">-->
<!--						<button class="btn dropdown-toggle" data-toggle="dropdown">更多操作 <i class="fa fa-angle-down"></i>-->
<!--						</button>-->
<!--						<ul class="dropdown-menu pull-right">-->
<!--							<li>-->
<!--								<a href="javascript:;" id="track_delete_btn">-->
<!--									批量删除-->
<!--								</a>-->
<!--							</li>-->
<!--						</ul>-->
<!--					</div>-->
				</div>
			</div>
		</div>
	</div>
		


		<div class="modal fade" id="dist_modal" role="dialog" aria-hidden="true">
			<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					<h4 class="modal-title">分配/转移</h4>
				</div>
				<div class="modal-body">
					<form action="" method="POST" class="form-horizontal" role="form">
						<input type="hidden" name="track_ids" id="track_ids" />												
						<div class="form-group">
							<label class="control-label col-md-4">转移拥有关系</label>
							<div class="col-sm-6">
								<select name="" id="new_owner" class="form-control" required="required">
										<?php foreach ($consultants as $consultant) :?>
					                        <option value="<?php echo $consultant['id']; ?>">
					                            <?php echo $consultant['nickname']; ?>的线索
					                        </option>
					                    <?php endforeach; ?>
								</select>
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-primary" id="dist_submit_btn">分配/转移</button>
				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
		</div><!-- /.modal -->


		<div class="modal fade" id="track_modal" role="dialog" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4 class="modal-title"><?php echo lang('clue_new_track');?></h4>
					</div>
					<div class="modal-body">
						<?php echo form_open($this->uri->uri_string(), array('class'=>'form-horizontal','role'=>'form')); ?>
	<!-- 				        <h3 class="form-section"><?php echo lang('clue_detail'); ?></h3>
	 -->		            <div class="form-group">
								<label class="control-label col-md-3" ><?php echo lang('clue_student_name_no'); ?><span class="required">*</span></label>
								<div class="col-md-9">
									<input type="text" name="" id="student_name" readonly class="form-control" value=" " />
									<input type="hidden" name="student_id" id="student_id" value="">
									<span class="help-block"></span>
								</div>
							</div>

							<div class="form-group<?php echo form_error('title') ? ' error' : ''; ?>">
								<label class="control-label col-md-3" ><?php echo lang('clue_track_title'); ?></label>
								<div class="col-md-9">
									<input type="text" name="title" id="title" class="form-control" value="<?php echo set_value('role_name', isset($role) ? $role->role_name : ''); ?>" />
									<span class="help-block"><?php echo form_error('title'); ?></span>
								</div>
							</div>

							<div class="form-group<?php echo form_error('track_wish') ? ' error' : ''; ?>">
								<label class="control-label col-md-3" ><?php echo lang('clue_trade_wish'); ?><span class="required">*</span></label>
								<div class="col-md-5">
									<select name="track_wish" id="track_wish" class="form-control" >
										<?php foreach(config_item('comm.trade_wish') as $key=>$value):?>
											<option value="<?php echo $key;?>" <?php echo set_select('track_wish', $key); ?>><?php echo $value;?></option>
										<?php endforeach;?>
									</select>
									<span class="help-block"><?php echo form_error('track_wish'); ?></span>
								</div>
							</div>

							<div class="form-group<?php echo form_error('track_result') ? ' error' : ''; ?>">
								<label class="control-label col-md-3" ><?php echo lang('clue_track_result'); ?><span class="required">*</span></label>
								<div class="col-md-5">
									<select name="track_result" id="track_result" class="form-control" >
										<?php foreach(config_item('comm.track_result') as $key=>$value):?>
											<option value="<?php echo $key;?>" <?php echo set_select('track_result', $key); ?>><?php echo $value;?></option>
										<?php endforeach;?>
									</select>
									<span class="help-block"><?php echo form_error('track_result'); ?></span>
								</div>
							</div>


							<div class="form-group<?php echo form_error('track_date') ? ' error' : ''; ?>">
								<label class="control-label col-md-3" ><?php echo lang('clue_track_date'); ?></label>
								<div class="col-md-5">
									<div class="input-group date date-picker">
										<input type="text" name="track_date" id="track_datee" class="form-control" value="<?php echo set_value('role_name', isset($role) ? $role->role_name : ''); ?>" />
										<span class="input-group-btn">
											<button class="btn default" type="button"><i class="fa fa-calendar"></i></button>
										</span>
									</div>
									<span class="help-block"><?php echo form_error('track_date'); ?></span>
								</div>
							</div>

							<div class="form-group<?php echo form_error('next_track_date') ? ' error' : ''; ?>">
								<label class="control-label col-md-3" ><?php echo lang('clue_next_track_date'); ?></label>
								<div class="col-md-5">
									<div class="input-group date date-picker">
										<input type="text" name="next_track_date" id="track_next_date" class="form-control" value="<?php echo set_value('next_track_date', isset($role) ? $role->role_name : ''); ?>" />
										<span class="input-group-btn">
											<button class="btn default" type="button"><i class="fa fa-calendar"></i></button>
										</span>
									</div>
									<span class="help-block"><?php echo form_error('next_track_date'); ?></span>
								</div>
							</div>

							<div class="form-group<?php echo form_error('content') ? ' error' : ''; ?>">
								<label class="control-label col-md-3" ><?php echo lang('clue_track_content'); ?></label>
								<div class="col-md-5">
									<textarea name="content" class="form-control"></textarea>
									<span class="help-block"><?php echo form_error('content'); ?></span>
								</div>
							</div>

							 <div class="form-group<?php echo form_error('user_id') ? ' error' : ''; ?>">
								<label class="control-label col-md-3" ><?php echo lang('clue_consultant'); ?><span class="required">*</span></label>
								<div class="col-md-5">
									<select class="form-control" name="consultant" id="consultant">
											<?php if (isset($consultants) && is_array($consultants) && count($consultants)) :?>
												<?php foreach ($consultants as $consultant) :?>
													 <option value="<?php echo $consultant['id']; ?>">
														<?php echo $consultant['nickname']; ?>
													</option>
												<?php endforeach; ?>
											<?php else:?>
												<option value="0">无</option>
											<?php endif;?>
									</select>
									<span class="help-block"><?php echo form_error('user_id'); ?></span>
								</div>
							</div>

					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo lang('action_cancel');?></button>
						<button type="submit" class="btn btn-primary" name="track"><?php echo lang('action_save');?></button>
					</div>

					<?php echo form_close();?>
				</div><!-- /.modal-content -->
			</div><!-- /.modal-dialog -->
		</div>
		<!-- /.modal -->
	</div>

<?php $this->load->view('footer');?>

<script type="text/javascript" src="assets/scripts/custom/track.js"></script>


<script>
jQuery(document).ready(function() {    
   App.init(); // initlayout and core plugins
   Track.init();
});
</script>

</body>
<!-- END BODY -->
</html>

